import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AgentMrVO, AgentMrForm, AgentMrQuery } from '@/api/business/agentMr/types';

/**
 * 查询医药代表管理列表
 * @param query
 * @returns {*}
 */

export const listAgentMr = (query?: AgentMrQuery): AxiosPromise<AgentMrVO[]> => {
  return request({
    url: '/business/agentMr/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询医药代表管理详细
 * @param id
 */
export const getAgentMr = (id: string | number): AxiosPromise<AgentMrVO> => {
  return request({
    url: '/business/agentMr/' + id,
    method: 'get'
  });
};

/**
 * 新增医药代表管理
 * @param data
 */
export const addAgentMr = (data: AgentMrForm) => {
  return request({
    url: '/business/agentMr',
    method: 'post',
    data: data
  });
};

/**
 * 修改医药代表管理
 * @param data
 */
export const updateAgentMr = (data: AgentMrForm) => {
  return request({
    url: '/business/agentMr',
    method: 'put',
    data: data
  });
};

/**
 * 删除医药代表管理
 * @param id
 */
// export const delAgentMr = (id: string | number | Array<string | number>) => {
//   return request({
//     url: '/business/agentMr/' + id,
//     method: 'delete'
//   });
// };
/**
 * 用户密码重置
 * @param userId 用户ID
 * @param password 密码
 */
export const resetUserPwd = (userId: string | number, password: string) => {
  const data = {
    userId,
    password
  };
  return request({
    url: '/business/agentMr/resetPwd',
    method: 'put',
    headers: {
      isEncrypt: true,
      repeatSubmit: false
    },
    data: data
  });
};

/**
 * 充值-次数
 * @param mrId
 * @param balance
 * @returns
 */
export const recharge = (mrId: string | number, balance: string | number) => {
  const data = {
    mrId,
    balance
  };
  return request({
    url: '/business/agentMr/recharge',
    method: 'put',
    headers: {
      isEncrypt: true,
      repeatSubmit: true
    },
    data: data
  });
};
